#define _CRT_SECURE_NO_WARNINGS 1
#include"stack.h"

typedef struct
{
    ST pushst;
    ST popst;
} MyQueue;


MyQueue* myQueueCreate()
{
    MyQueue* obj = (MyQueue*)malloc(sizeof(MyQueue));
    STInit(&obj->pushst);
    STInit(&obj->popst);
    return obj;
}

void myQueuePush(MyQueue* obj, int x)
{
    STPush(&(obj->pushst), x);
}
int myQueuePeek(MyQueue* obj)
{
    if (STEmpty(&obj->popst))
    {
        while (!STEmpty(&(obj->pushst)))
        {
            int top = STTop(&obj->pushst);
            STPop(&obj->pushst);
            STPush(&obj->popst, top);
        }
    }
    return STTop(&obj->popst);
}
int myQueuePop(MyQueue* obj)
{
    int front = myQueuePeek(&obj->popst);
    STPop(&obj->popst);
    return front;
}
bool myQueueEmpty(MyQueue* obj)
{
    return STEmpty(&obj->pushst) && STEmpty(&obj->popst);
}

void myQueueFree(MyQueue* obj)
{
    STDestroy(&obj->pushst);
    STDestroy(&obj->popst);
    free(obj);
}